<h2>Envoi de fichiers</h2>

<div class="button-box">
	<?= button_link('admin/medias/file_new', 'Envoyer un fichier', 'add') ?>
</div>
<table class="dataTable">
	<thead>
		<tr>
			<th>Nom</th>
			<th>Type</th>
			<th>Taille</th>
			<th>Envoyé le</th>
			<th>Actions</th>
		</tr>
	</thead>
	<tbody>
		<?php
		$dummy_id = 0;
		$total_size = 0;
		foreach ($files as $file) {
			$info = pathinfo($file);
			++$dummy_id;
			$dl_link = base_url().ADMIN_UPLOAD_DIR.'/'.$info['basename'];
			?>
			<tr id="file_<?= $dummy_id ?>">
				<td><?= anchor($dl_link, $info['basename'], 'class="link"') ?></td>
				<td class="center">
					<?php $icon = ext_to_icon($info['extension']);
					echo '<span class="hidden">'.$icon.'</span>';
					echo icon_tag($icon, 'title="'.$icon.'"'); ?>
				</td>
				<td class="number">
					<?php $size = filesize($file);
					$total_size += $size;
					echo '<span class="hidden">'.sprintf("%10d",  $size).'</span>';
					echo bytes_symbol($size);
					?>
				</td>
				<td><?= timestamp_to_str(filemtime($file)) ?></td>
				<td class="actions">
					<a href="javascript:file_delete('<?= $info['basename'] ?>', <?= $dummy_id ?>)" class="js-confirm" title="Supprimer ce fichier">
						<?= icon_tag('cross') ?>
					</a>
					<?= anchor('admin/medias/download/'.$info['basename'], icon_tag('drive_go'), 'title="Télécharger"') ?>
				</td>
			</tr>
		<?php } ?>
	</tbody>
</table>
<p>
	Espace total occupé : <strong><?= bytes_symbol($total_size) ?></strong>
</p>
<p>
	Vous pouver ouvrir un document en cliquant sur son nom, ou forcer son téléchargement en cliquant sur l'icône <?= icon_tag('drive_go') ?>
</p>
